package com.vcc.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.vcc.data.entity.RiskRule;
import com.vcc.data.mapper.RiskRuleMapper;
import com.vcc.service.service.RiskRuleService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RiskRuleServiceImpl extends ServiceImpl<RiskRuleMapper, RiskRule> implements RiskRuleService {
    @Override
    public Boolean existsByRiskId(List<Long> riskIds, String key, String fun, String value) {
        return queryChain()
                .in(RiskRule::getRiskId, riskIds)
                .eq(RiskRule::getKey, key)
                .eq(RiskRule::getFun, fun)
                .eq(RiskRule::getValue, value)
                .exists();
    }

    @Override
    public List<RiskRule> listByRiskId(List<Long> riskIds) {
        return queryChain()
                .in(RiskRule::getRiskId, riskIds)
                .list();
    }

    @Override
    public List<RiskRule> listByRiskId(Long riskId) {
        return queryChain()
                .eq(RiskRule::getRiskId, riskId)
                .list();
    }

    @Override
    public Boolean removeByRiskId(Long riskId) {
        return remove(
                queryChain()
                        .eq(RiskRule::getRiskId, riskId)
        );
    }
}
